package com.lqm.util;

import com.lqm.entity.home.Project;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * @program: CrowdFunding
 * @description
 * @author: lqm
 * @create: 2018-12-13 17:29
 */

public class FormatProjectUtil {


    /**
     * 格式化 项目 中转json 双向调用问题
     *
     * @param project
     * @return
     */
    public static Project formatProjectList(Project project) {

        //将剩余天数格式化
        Timestamp end_time = project.getEndTime();
        //结束时间
        long end = end_time.getTime();
        //当前时间
        long cu = System.currentTimeMillis();
        int newL = (int) ((end - cu) / (1000 * 3600 * 24));
        if (newL<0){
            newL=0;
        }
        //屏蔽一些信息
        project.getHomeUser().setUserAddresses(null);
        project.getHomeUser().setPassword(null);
        project.getHomeUser().setProjects(null);

        project.setDay(newL + "");

        return project;
    }
}
